﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace WordpressRestApi
{
    /// <summary>Client for the User API.</summary>
    /// <remarks>See https://developer.wordpress.com/docs/api/ for the endpoints available..</remarks>
    public class UserClient : ApiClientBase
    {
        /// <summary>Constructor.</summary>
        /// <param name="token"></param>
        internal UserClient(TokenInfo token)
            : base(token)
        {
        }

        /// <summary>Get metadata about the current user.</summary>
        /// <remarks>See https://developer.wordpress.com/docs/api/1.1/get/me/ for API.</remarks>
        /// <returns>Current user metadata.</returns>
        public async Task<UserMetadataInfo> GetMeAsync()
        {
            var url = API_ROOT + "me";
            var user = await GetRequestAsync<UserMetadataInfo>(url);

            return user;
        }
    }
}